import { request } from "@/utils/request";

//提交评论
export function submitComment(params) {
    return request({
        method: 'post',
        url: '/comment/insertComment',
        data: params,
        headers: {
            'token': window.localStorage.token,
        },
    })
}

//根据文章id获取评论
export function getCommentListById(id) {

    //将id拼接到url上面
    const encodedId = encodeURIComponent(id);
    const url = `/comment/getComments?articleId=${encodedId}`;

    return request({
        method: 'post',
        url: url,
        headers: {
            'token': window.localStorage.token,
        }
    })
}

//获取文章评论数
export function getCommentCount(params){
    return request({
        method:'get',
        url:'/comment/commentCount',
        params:params,
        headers: {
            'token': window.localStorage.token,
        }
    })
}